package com.base.object.each;

public class Each04 {
    public static void main(String[] args) throws Exception {
        Animal dog = new Animal("Dog") ;
        Animal copyDog = dog.clone() ;
        if (dog != copyDog){
            System.out.println("对象地址是否相同："+Boolean.FALSE);
        }
        if (dog.getClass() == copyDog.getClass()){
            System.out.println("Class是否相同："+Boolean.TRUE);
        }
        if (dog.getName() == copyDog.getName()){
            System.out.println("变量地址是否相同："+Boolean.TRUE);
        }
    }
}
class Animal implements Cloneable {
    private String name ;
    public Animal(String name) {
        this.name = name;
    }
    @Override
    protected Animal clone() throws CloneNotSupportedException {
        return (Animal)super.clone();
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
